﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HR60_PanelSoft.Model;
using HR60_PanelSoft.Model.BaseModel;
using HR60_PanelSoft.View.Base;


namespace HR60_PanelSoft.View.TabForms.ListItems
{
	public partial class SceneAttrItem : BaseFormControl
	{
		CtrlAttr ctrlAttr = null;

		public SceneAttrItem(CtrlAttr ctrlAttr)
		{
			InitializeComponent();

			this.ctrlAttr = ctrlAttr;
			cbEnabled.Checked = false;
			txtName.Text = ctrlAttr.name;
			selValue.bindData(ctrlAttr.values);

			cbEnabled.CheckedChanged += new EventHandler(valueChange);
			selValue.ValueChanged += new EventHandler(valueChange);
		}

		// 目标设备
		public CtrlAttr TagAttr
		{
			get
			{
				return ctrlAttr;
			}
		}

		// 重写Value属性，返回属性Value的Key
		public override object Value
		{
			get
			{
				if (cbEnabled.Checked)
				{
					return selValue.Text;
				}
				else
				{
					return null;
				}
			}
			set
			{
				if (value == null)
				{
					cbEnabled.Checked = false;
				}
				else
				{
					selValue.Text = (string) value;
				}
			}
		}
	}
}
